﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SQLite;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace classwork11
{
    public partial class Form1 : Form
    {

        string answer;
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox3.Text == answer)
            {
                label4.Text = "回答正确";
            }
            else
            {
                label4.Text = "回答错误\n" + "正确答案是：" + answer;
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            string dataConnPath = @"Data Source =..\..\..\db\word.db";
            SQLiteConnection dataConn = new SQLiteConnection(dataConnPath);
            dataConn.Open();
            SQLiteCommand command = new SQLiteCommand("SELECT * FROM word ORDER BY RANDOM()", dataConn);
            command.ExecuteNonQuery();

            SQLiteDataReader data = command.ExecuteReader();
            while (data.Read())//读取
            {
                textBox1.Text = data["Chinese"].ToString();
                textBox2.Text = data["Attribute"].ToString();
                textBox3.Text = "";
                answer = data["English"].ToString();
            }
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {

        }

        private void textBox3_TextChanged(object sender, EventArgs e)
        {

        }

        private void label4_Click(object sender, EventArgs e)
        {

        }
    }
}

     

     

      